import {_decorator, Component, Node, SpriteFrame, CCInteger, Sprite} from 'cc';
import {RenderManager} from "db://assets/Scripts/Base/RenderManager";
import DataManager from "db://assets/Scripts/Runtime/DataManager";

const {ccclass, property} = _decorator;


@ccclass('ContentManager')
export class ContentManager extends RenderManager {
    @property(SpriteFrame)
    normalSf: SpriteFrame = null // 灰色棋子图片

    @property(SpriteFrame)
    successSf: SpriteFrame = null // 青绿色棋子图片

    @property(CCInteger)
    index: number

    render() {
        const curIndex = DataManager.Instance.H2AData.findIndex(i => i === this.index)
        const answerIndex = DataManager.Instance.H2AAnswer.findIndex(i => i === this.index)
        this.getComponent(Sprite).spriteFrame = curIndex === answerIndex ? this.successSf : this.normalSf
    }
}
